# -*- coding: utf-8 -*-
# !/usr/bin/env python
from utils.mysql_utils import query_to_list


def sys_other_privilege_dict(sys_other_privilege_flag=''):
    sql_parameter = []

    if sys_other_privilege_flag:
        sql_fragment = "WHERE a.sys_other_privilege_flag = %s"
        sql_parameter.append(sys_other_privilege_flag)
    else:
        sql_fragment = ''

    sql = """
    SELECT  * FROM sys_other_privilege a
    %s
    """%sql_fragment
    data = query_to_list(sql, sql_parameter, True)

    return data

def sys_other_privilege_dict_in_url_pass(url):
    if url.find("https://") != -1:
        now_url = "https://" + url.replace("https://","{nexus_user}:{nexus_pass}@")
    elif url.find("http://") != -1:
        now_url = "http://" + url.replace("http://","{nexus_user}:{nexus_pass}@")
    else:
        now_url = "{nexus_user}:{nexus_pass}@" + url
    return now_url
